zynqmp: pm: Allow to set shutdown scope via pm_system_shutdown API
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Mon, 30 Apr 2018 10:26:10 +0000 (15:56 +0530)
committerSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Thu, 17 May 2018 09:42:44 +0000 (15:12 +0530)
psci system_reset and system_off calls now retrieve shutdown scope on
the fly. The default scope is system, but it can be changed by calling
pm_system_shutdown(2, scope)

Until full support for different restart scopes becomes available with
PSCI 1.1 this change allows users to set the reboot scope to match
their application needs.

Possible scope values:
0 - APU subsystem: does not affect RPU, PMU or PL
1 - PS only: shutdown/restart entire PS without affecting PL
2 - System: shutdown/restart applies to entire system

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Davorin Mista <davorin.mista@aggios.com>
plat/xilinx/zynqmp/plat_psci.c
plat/xilinx/zynqmp/pm_service/pm_api_sys.c
plat/xilinx/zynqmp/pm_service/pm_api_sys.h
plat/xilinx/zynqmp/pm_service/pm_defs.h

index 27cdddb2c89e9060b7bf772aaf924b19e5543a6f..d0df6a87144b797e6863d48e9168b55d47d9d3a7 100644 (file)
@@ -249,7 +249,7 @@ static void __dead2 zynqmp_system_off(void)
 
        /* Send the power down request to the PMU */
        pm_system_shutdown(PMF_SHUTDOWN_TYPE_SHUTDOWN,
-                          PMF_SHUTDOWN_SUBTYPE_SUBSYSTEM);
+                          pm_get_shutdown_scope());
 
        while (1)
                wfi();
@@ -284,7 +284,7 @@ static void __dead2 zynqmp_system_reset(void)
 
        /* Send the system reset request to the PMU */
        pm_system_shutdown(PMF_SHUTDOWN_TYPE_RESET,
-                          PMF_SHUTDOWN_SUBTYPE_SUBSYSTEM);
+                          pm_get_shutdown_scope());
 
        while (1)
                wfi();
index d746c286579a5d4fff8daea573bea7cde24dc024..4b709abff67cdb6adfc36ad45f01fb9511b03cc7 100644 (file)
 #include "pm_common.h"
 #include "pm_ipi.h"
 
+/* default shutdown/reboot scope is system(2) */
+static unsigned int pm_shutdown_scope = PMF_SHUTDOWN_SUBTYPE_SYSTEM;
+
+/**
+ * pm_get_shutdown_scope() - Get the currently set shutdown scope
+ *
+ * @return     Shutdown scope value
+ */
+unsigned int pm_get_shutdown_scope(void)
+{
+       return pm_shutdown_scope;
+}
+
 /**
  * Assigning of argument values into array elements.
  */
@@ -215,7 +228,8 @@ enum pm_ret_status pm_set_wakeup_source(enum pm_node_id target,
 
 /**
  * pm_system_shutdown() - PM call to request a system shutdown or restart
- * @restart    Shutdown or restart? 0 for shutdown, 1 for restart
+ * @type       Shutdown or restart? 0=shutdown, 1=restart, 2=setscope
+ * @subtype    Scope: 0=APU-subsystem, 1=PS, 2=system
  *
  * @return     Returns status, either success or error+reason
  */
@@ -223,6 +237,12 @@ enum pm_ret_status pm_system_shutdown(unsigned int type, unsigned int subtype)
 {
        uint32_t payload[PAYLOAD_ARG_CNT];
 
+       if (type == PMF_SHUTDOWN_TYPE_SETSCOPE_ONLY) {
+               /* Setting scope for subsequent PSCI reboot or shutdown */
+               pm_shutdown_scope = subtype;
+               return PM_RET_SUCCESS;
+       }
+
        PM_PACK_PAYLOAD3(payload, PM_SYSTEM_SHUTDOWN, type, subtype);
        return pm_ipi_send(primary_proc, payload);
 }
index 135bcc800c275807bcf4a2ff7b27229f5cc27cb4..e850b79e127ab739b7361775a4e2d9b48ae38b01 100644 (file)
@@ -114,6 +114,7 @@ enum pm_ret_status pm_secure_rsaaes(uint32_t address_high,
                                    uint32_t size,
                                    uint32_t flags);
 void pm_get_callbackdata(uint32_t *data, size_t count);
+unsigned int pm_get_shutdown_scope(void);
 enum pm_ret_status pm_pinctrl_request(unsigned int pin);
 enum pm_ret_status pm_pinctrl_release(unsigned int pin);
 enum pm_ret_status pm_pinctrl_get_function(unsigned int pin,
index 1938c198bb743fc4579387dfd074172204e4a9bb..cc514451791e0c5f079b22424c2921164d81d534 100644 (file)
@@ -239,11 +239,22 @@ enum pm_boot_status {
        PM_BOOT_ERROR,
 };
 
+/**
+ * @PMF_SHUTDOWN_TYPE_SHUTDOWN:                shutdown
+ * @PMF_SHUTDOWN_TYPE_RESET:           reset/reboot
+ * @PMF_SHUTDOWN_TYPE_SETSCOPE_ONLY:   set the shutdown/reboot scope
+ */
 enum pm_shutdown_type {
        PMF_SHUTDOWN_TYPE_SHUTDOWN,
        PMF_SHUTDOWN_TYPE_RESET,
+       PMF_SHUTDOWN_TYPE_SETSCOPE_ONLY,
 };
 
+/**
+ * @PMF_SHUTDOWN_SUBTYPE_SUBSYSTEM:    shutdown/reboot APU subsystem only
+ * @PMF_SHUTDOWN_SUBTYPE_PS_ONLY:      shutdown/reboot entire PS (but not PL)
+ * @PMF_SHUTDOWN_SUBTYPE_SYSTEM:       shutdown/reboot entire system
+ */
 enum pm_shutdown_subtype {
        PMF_SHUTDOWN_SUBTYPE_SUBSYSTEM,
        PMF_SHUTDOWN_SUBTYPE_PS_ONLY,